package cn.rui.common.listen;

import org.springframework.stereotype.Component;

import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;

/**
 * http监听
 * @author 徽州大都督
 * @date 2021/4/19
 */
@Component
public class MyHttpSessionListener implements HttpSessionListener {

    /**
     * 因为用户退出有可能直接关闭浏览器等非正常操作，所以这里直接用session监听器去监听
     */
    @Override
    public void sessionCreated(HttpSessionEvent httpSessionEvent) {

    }

    @Override
    public void sessionDestroyed(HttpSessionEvent httpSessionEvent) {
        String loginName= (String) httpSessionEvent.getSession ().getAttribute ("loginName");
        System.out.println ("退出系统用户："+loginName);
    }


}
